package com.spring.fisher.controller;

import com.spring.fisher.bean.Users;
import com.spring.fisher.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {

    private  final Logger log= LoggerFactory.getLogger(UserController.class);

    @Autowired
    UserService userService;

    @RequestMapping(value = "/queryUser1", method = RequestMethod.GET)
    public ResponseEntity<List<Users>> queryUser1() {
        List<Users> usersList = userService.queryUser1();
        // 返回结果为 usersList
        return new ResponseEntity<>(usersList, HttpStatus.OK);
    }

    @GetMapping("/queryUser2")
    public ResponseEntity<List<Users>> queryUser2() {
        List<Users> usersList = userService.queryUser2();
        // 返回结果为 usersList
        return new ResponseEntity<>(usersList, HttpStatus.OK);
    }

    @RequestMapping(value = "/queryUser", method = RequestMethod.GET)
    public String queryUser(@RequestParam String userName) {
        System.out.println("queryUser");
        return userName;
    }
}
